#include "Bullet.h"
#include <ctime>


Bullet::Bullet(const Bullet & obj, bool copyScene): DynamicObject(obj, copyScene)
{
    id = obj.id;
}

Bullet::Bullet(int ID, int Speed, int X, int Y, char Direction, double Progres):
    id(ID), DynamicObject(X, Y,Direction, Speed, Progres)
{}

QRectF Bullet::boundingRect() const
{
    return(QRectF(0, 0, 10, 10));
}


void Bullet::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{
    // TODO
}


bool Bullet::advanceAction(long duration)
{
    m_progress += static_cast<double>(duration) / CLOCKS_PER_SEC * m_speed * 100;

    if (m_progress >= 100.0)
    {
        m_progress -= 100.0;

        switch (m_direction)
        {
        case 'L':
            m_posX--;
            break;
        case 'R':
            m_posX++;
            break;
        case 'U':
            m_posY--;
            break;
        default:
            m_posY++;
        }

        return true;
    }

    return false;
}

int Bullet::GetID()
{
    return id;
}

void Bullet::SetID(int ID)
{
    id = ID;
}
